<%@ page contentType="text/html;charset=utf-8" %>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="jsp.util.ConnectionContext" %>
<%@ page import="java.sql.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%
	// paginator
	String pageNum = request.getParameter("pageNum");
	if(pageNum == null){
		pageNum = "1";
	}

	int listSize = 7;
	int currentPage = Integer.parseInt(pageNum);
	int nextPage = currentPage + 1;
	int startRow = (currentPage - 1) * listSize + 1;
	int endRow = currentPage * listSize;
	int lastRow = 0;
	int i = 0;
	int num[] = {0};
	int row = startRow;
%>







<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">

<style type="text/css">

.space{padding-right:10%; padding-left:10%}
 
        #wrapper{width:800px;border:1px solid #eee; margin:20px auto;}
 
        #sub,#body{float:left;}
 
        #sub{wisth:150px;}
 
        #body{width:800px;height:450px;}
 		#head1{height:100px;}
        #head2{height:40px;background:#eee;}
 
        #foot{clear:both;height:30px;background:#eee;}
        
#tabs{margin:0; height:40px; border-bottom:1px solid #696;font-family;'돋움','돋움체',Dotum,'굴림','굴림체',Dulin,Arial;}
#tabs li.top {display:block; float:left;}


#tabs li a.top_link {display:block; float:left; height:36px; line-height:27px; color:#ccc; text-decoration:none; font-size:11px; font-weight:bold; padding:0 0 0 12px; cursor:pointer;background: url(blank.gif);}
#tabs li a.top_link span {float:left; display:block; padding:0 24px 0 12px; height:36px;background:url(blank.gif) right top;}
#tabs li a.top_link span.down {float:left; display:block; padding:0 24px 0 12px; height:36px; background:url(blanka.gif) no-repeat right top;}
#tabs li a.top_link:hover {color:#fff; background: url(blank_over.gif) no-repeat;}
#tabs li a.top_link:hover span {background:url(blank_over.gif) no-repeat right top;}
#tabs li a.top_link:hover span.down {background:url(blank_overa.gif) no-repeat right top;}

#tabs li {margin:0; padding-top:13px; display:block; float:left; list-style-type:none; width:150px; height:30px; text-align:center;}
#tabs a{float:left;  font-weight:bold; width:100px; height:23px; text-decoration:none; font-family:돋움, 돋움체; font-size:14px; color:#9c9;}
#tabs a:hover {border-bottom:3px solid #699; color:#363;}
#tabs a:hover {color:#696;}

#tabs li:hover > a.top_link {color:#fff; background: url(blank_over.gif) no-repeat;}
#tabs li:hover > a.top_link span {background:url(blank_over.gif) no-repeat right top;}
#tabs li:hover > a.top_link span.down {background:url(blank_overa.gif) no-repeat right top;}

/* Default list styling */

#tabs li:hover {position:relative; z-index:200;}

/* keep the 'next' level invisible by placing it off screen. */
#tabs ul, 
#tabs li:hover ul ul,
#tabs li:hover ul li:hover ul ul,
#tabs li:hover ul li:hover ul li:hover ul ul,
#tabs li:hover ul li:hover ul li:hover ul li:hover ul ul
{position:absolute; left:-9999px; top:-9999px; width:0; height:0; margin:0; padding:0; list-style:none;}

#tabs li:hover ul.sub
{left:0; top:31px; background: #fff; padding:3px; border:1px solid #3a93d2; white-space:nowrap; width:130px; height:auto; z-index:300;}
#tabs li:hover ul.sub li
{display:block; height:20px; position:relative; float:left; width:90px; font-weight:normal;}
#tabs li:hover ul.sub li a
{display:block; font-size:11px; height:20px; width:130px; line-height:20px; text-indent:5px; color:#000; text-decoration:none;}
#tabs li ul.sub li a.fly
{background:#fff url(arrow.gif) 80px 7px no-repeat;}
#tabs li:hover ul.sub li a:hover 
{background:#3a93d2; color:#fff;}
#tabs li:hover ul.sub li a.fly:hover
{background:#3a93d2 url(arrow_over.gif) 80px 7px no-repeat; color:#fff;}
#tabs li:hover ul li:hover > a.fly {background:#3a93d2 url(arrow_over.gif) 80px 7px no-repeat; color:#fff;} 

#tabs li:hover ul li:hover ul,
#tabs li:hover ul li:hover ul li:hover ul,
#tabs li:hover ul li:hover ul li:hover ul li:hover ul,
#tabs li:hover ul li:hover ul li:hover ul li:hover ul li:hover ul
{left:90px; top:-4px; background: #fff; padding:3px; border:1px solid #3a93d2; white-space:nowrap; width:90px; z-index:400; height:auto;}


</style>

</head>
<body>

<div id="wrapper" style="border:1px solid #696">
 <div id="head1" style="border:1px solid #696">
 </div>
 <div id="head2" style="border:1px solid #696">
 
 
		<ul id="tabs">
		<li class="top"><a href="Main.jsp">Home</a>
			<ul class="sub">
				<li><a href="Main.jsp">Main</a></li>
				<li><a href="Board.jsp">Board</a></li>
				<li><a href="Photoalbum.jsp">Photo Album</a></li>
			</ul>
		</li>
		<li class="top"><a href="Notice.jsp">Notice</a></li>
		<li class="top"><a href="Prof.jsp">Prof.</a>
			<ul class="sub">
				<li><a href="Chang.jsp" class="fly">Chang Byung Mo </a></li>
				<li><a href="http://cs.sookmyung.ac.kr/~snaglee" class="fly">Lee Gwang Soo</a></li>	
				<li><a href="http://cs.sookmyung.ac.kr/~snaglee" class="fly">Moon Bong Hee</a></li>	
				<li><a href="http://cs.sookmyung.ac.kr/~snaglee" class="fly">Lee Sang Gyu</a></li>	
				<li><a href="ParkSookYoung.jsp" class="fly">Park Sook Young</a></li>
				<li><a href="Chang.jsp" class="fly">Kim Joo Kyun </a></li>
				<li><a href="Chang.jsp" class="fly">Choi Jong Won</a></li>
				<li><a href="Chang.jsp" class="fly">Choi Young Woo </a></li>
				<li><a href="Chang.jsp" class="fly">Shim Joon Ho </a></li>
				<li><a href="Chang.jsp" class="fly">Kim Yoon Hee </a></li>
				<li><a href="Chang.jsp" class="fly">Yoo Suk Jong </a></li>
				<li><a href="Chang.jsp" class="fly">Lee Ki Yong </a></li>
				<li><a href="Chang.jsp" class="fly">Kim Yoon Jin </a></li>
				<li><a href="Chang.jsp" class="fly">Lee Hyung Ja </a></li>	
			</ul>
		</li>
		<li><a href="Myclass.jsp">My class</a></li>
		<li><a href="Mypage.jsp">My page</a></li>
	
		</ul>
		</div>
		 <div id="body" style="border:1px solid #696">
		 
		 <h2>Notice</h2><p>
<div class="space"> 
<center>
	<select name="말머리">
		<option value="">말머리를 선택하세요</option>
		<option value="Title">제목</option>
	</select>	
	
	<input type="text" size="20">
	<input type="button" name="BTNsearch" value="Search">
</div>
<p></p>


<TABLE border="1"> 
<TR>
	<TD> Number </TD>
	<TD> Title</TD>
	<TD> Prof. </TD>
	<TD> Date </TD>
	<TD> Count </TD>	
</TR>
<%

		int numbering=1; 
		
		
	try{
		// 데이터베이스 커넥션 생성
		Connection conn = ConnectionContext.getConnection();

		// Statement 생성
		Statement stmt = conn.createStatement();
		
		// ReseltSet의 레코드 수를 lastRow 변수에 저장
		String strSQL = "SELECT count(*) FROM profnotice";
		ResultSet rs = stmt.executeQuery(strSQL);
		
		if(rs.next())
			lastRow = rs.getInt(1);
		rs.close();
		
		// ResultSet에 레코드가 존재할 때
		if(lastRow > 0) {
				strSQL = "SELECT * FROM profnotice";
				rs = stmt.executeQuery(strSQL);				
				for(i=1;rs.next(); i++){
					if(i >= startRow && i <=endRow){
%>
					<TR>
						<TD><%=numbering%></TD>
						
						
						<TD>
						<a href="ProfNoticeView.jsp">
						<%=rs.getString("title") %>
						</a>
						</TD>
						
						
						<TD><%=rs.getString("profName") %></TD>
						<TD><%=rs.getDate("registerDate") %></TD>
						<TD><%=rs.getInt("count") %></TD>

					</TR>
<%						row++;
						numbering++;
					}
				}
				rs.close();
//			}
			// 사용한 Statement 종료
			stmt.close();
			// 커넥션 종료
			//conn.close();
		}
		else
		{
%>
<TR>
	<TD colspan="4"> 레코드 없음 </TD>
</TR>
<%
		}

	}catch(SQLException ex){ 
%>
<TR>
	<TD colspan="4"> 에러: <%=ex %> </TD>
</TR>
<%
	}
%>

</TABLE>
<%
	if(lastRow > 0) {
		// 페이지가 넘어갈 때 넘겨줄 파라미터
		int setPage = 1;
		
		// 마지막 페이지의 번호를 저장
		int lastPage = 0;
		if(lastRow % listSize == 0)
			lastPage = lastRow / listSize;
		else
			lastPage = lastRow / listSize + 1;
		
		
		if(setPage<currentPage)
		{
%>
			<a href="memberlist.jsp?pageNum=<%=currentPage-1%>">◀</a>
<%}
		
		// 레코드 수에 따라 쪽번호를 매긴다.	
		while(setPage <= lastPage) {
			
		if(setPage != currentPage){
%>
		<a href="memberlist.jsp?pageNum=<%=setPage%>">[<%=setPage%>]</a>
<%
		}
		else{
	%>
		[<%=setPage%>]
	<% }
			setPage = setPage + 1;
		}
		
	
		// 현재 쪽번호에 따라 다음 쪽의 번호를 파라메터로 넘겨준다.
		if(lastPage > currentPage) {
%>
		<a href="memberlist.jsp?pageNum=<%=currentPage+1%>">▶</a>
<%
		}
	}
%>

		 
		 </div>
 
	</div>

</center>
</body>
</html>